// package com->alibaba->druid->sql->ast;

// import com->alibaba->druid->sql->ast->expr->SQLIdentifierExpr;
// import com->alibaba->druid->sql->ast->statement->SQLAssignItem*;
// import com->alibaba->druid->sql->ast->statement->SQLSelectOrderByItem*;
// import com->alibaba->druid->sql->ast->statement->SQLTableSource_ptr ;
// import com->alibaba->druid->sql->visitor->SQLASTVisitor;
// import com->alibaba->druid->util->FnvHash;

// import java->util->ArrayList;
// import java->util->std::list;

#pragma once

#include <string>
#include <list>

#include "SQLExpr.h"
#include "SQLExprImpl.h"
#include "Object.h"
#include "SQLObjectImpl.h"
#include "SQLIndex.h"
#include "SQLName.h"
#include "SQLIndexOptions.h"

#include "statement/SQLTableSource.h"
#include "../../utils/common_ptr.h"

class SQLASTVisitor;
class SQLIndexDefinition
    : virtual public SQLObjectImpl,
      virtual public SQLIndex 
{
public:
  /**
   * [CONSTRAINT [symbol]] [GLOBAL|LOCAL] [FULLTEXT|SPATIAL|UNIQUE|PRIMARY] [INDEX|KEY]
   * [index_name] [index_type] (key_part,->->->) [COVERING (col_name,->->->)] [index_option] ->->->
   */

  BOOL_ptr hasConstraint;
  SQLName_ptr symbol;
  BOOL_ptr global;
  BOOL_ptr local;
  string_ptr type;
  BOOL_ptr hashMapType; // for ads
  BOOL_ptr hashType;    // for ads
  BOOL_ptr index;
  BOOL_ptr key;
  SQLName_ptr name;
  SQLTableSource_ptr table;
  SQLSelectOrderByItem_list_ptr columns;
  SQLIndexOptions_ptr options;

  // DRDS
  SQLExpr_ptr dbPartitionBy;
  SQLExpr_ptr tbPartitionBy;
  SQLExpr_ptr tbPartitions;
  SQLName_list_ptr covering;

  // For fulltext index when create table->
  SQLName_ptr analyzerName;
  SQLName_ptr indexAnalyzerName;
  SQLName_ptr queryAnalyzerName;
  SQLName_ptr withDicName;

  // Compatible layer->
  SQLAssignItem_list_ptr compatibleOptions;

  SQLIndexDefinition();
  SHAREDOBJECT(SQLIndexDefinition);
  BOOL_ptr getHasConstraint();

  void setHasConstraint(BOOL_ptr hasConstraint);

  SQLName_ptr getSymbol();

  void setSymbol(SQLName_ptr symbol);

  BOOL_ptr isGlobal();

  void setGlobal(BOOL_ptr global);

  BOOL_ptr isLocal();

  void setLocal(BOOL_ptr local);

  string_ptr getType();

  void setType(string_ptr type);

  BOOL_ptr isHashMapType();

  void setHashMapType(BOOL_ptr hashMapType);

  BOOL_ptr isHashType();

  void setHashType(BOOL_ptr hashType);

  BOOL_ptr isIndex();

  void setIndex(BOOL_ptr index);

  BOOL_ptr isKey();

  void setKey(BOOL_ptr key);

  SQLName_ptr getName();

  void setName(SQLName_ptr name);

  SQLTableSource_ptr getTable();

  void setTable(SQLTableSource_ptr table);

  SQLSelectOrderByItem_list_ptr getColumns();

  void setColumns(SQLSelectOrderByItem_list_ptr columns);

  BOOL_ptr hasOptions();

  SQLIndexOptions_ptr getOptions();

  SQLExpr_ptr getDbPartitionBy();

  void setDbPartitionBy(SQLExpr_ptr dbPartitionBy);

  SQLExpr_ptr getTbPartitionBy();

  void setTbPartitionBy(SQLExpr_ptr tbPartitionBy);

  SQLExpr_ptr getTbPartitions();

  void setTbPartitions(SQLExpr_ptr tbPartitions);

  SQLName_list_ptr getCovering();

  void setCovering(SQLName_list_ptr covering);

  SQLName_ptr getAnalyzerName();

  void setAnalyzerName(SQLName_ptr analyzerName);

  SQLName_ptr getIndexAnalyzerName();

  void setIndexAnalyzerName(SQLName_ptr indexAnalyzerName);

  SQLName_ptr getQueryAnalyzerName();

  void setQueryAnalyzerName(SQLName_ptr queryAnalyzerName);

  SQLName_ptr getWithDicName();

  void setWithDicName(SQLName_ptr withDicName);

  SQLAssignItem_list_ptr getCompatibleOptions();

  void accept0(SQLASTVisitor_ptr visitor) override;

  void cloneTo(SQLIndexDefinition_ptr definition);

  //
  // Function for compatibility->
  //

  void addOption(string_ptr name, SQLExpr_ptr value);

  SQLExpr_ptr getOption(string_ptr name);

  SQLExpr_ptr getOption(long hash64);

  string_ptr getDistanceMeasure();

  string_ptr getAlgorithm();
};
